//
//  Camera_h
//  RenderV1
//
//  Created by 黄翔 on 2019/8/25.
//  Copyright © 2019 黄翔. All rights reserved.
//

#ifndef Camera_h
#define Camera_h

#include "HMath.h"
#include "Component.h"
#include <vector>

namespace hxe {
    typedef enum CameraClearFlags 
    { 
        SolidColor = 0,
        Depth = 1, 
        Nothing = 2, 
        Skybox = 3,
    } CameraClearFlags;

    class Camera: public Component
    {
    public:
        float near;
        float far;
        float fov;
        float aspect;
        bool orthographic;
        float orthographicSize;
        CameraClearFlags clearFlags;
        Color backgroundColor;
        int cullingMask;
        int depth;

    private:
        static bool sortFun(const Camera* a, const Camera* b);
        static Camera* main;

    public:
        static Camera* current;
        static std::vector<Camera*>* allCameras;
        static void sortCamera();

        static Camera* getMainCamera();
        
    public:
        Camera(Vector3 forward, Vector3 up, float fov, float aspect, float near, float far);

        Camera(float orthographicSize, float aspect, float near, float far);
        
        Matrix4x4 getViewProjectionMatrix() const;

        virtual Matrix4x4 getViewMatrix() const;

        virtual Matrix4x4 getProjectionMatrix() const;
        
    public:
        virtual void begin();
        virtual void update();
    };
}

#endif /* Camera_h */
